import { message } from '@/utils';
import { useUserStore } from '@/store';

export default function useUser() {
  const router = useRouter();
  const logout = async (logoutTo?: string) => {
    const userStore = useUserStore();
    const currentRoute = router.currentRoute.value;
    userStore.logoutCallBack();
    message({
      content: '登出成功',
      cb: () => {
        router.push({
          name: 'login',
          query: {
            ...router.currentRoute.value.query,
            // redirect: currentRoute.name as string,
          },
        });
      },
    });
  };
  return {
    logout,
  };
}
